package com.hjq.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

@Component
@Configuration
public class UploadConfig {
    /**
     * 配置文件解析器
     * 设置单个文件大小上限为10M
     */
    @Bean
    public MultipartResolver multipartResolver() {
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        // 设置上传大小为 10M
        multipartResolver.setMaxUploadSize(1024 * 1024 * 10);
        return multipartResolver;
    }
}
